package com.huilian.iotbox.admin.wap.controller;


import com.huilian.iotbox.admin.wap.service.UserBankCardService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.po.UserBankCard;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 谢洛涛
 * @date 2021/4/8 10:22
 */
@RestController
@RequestMapping("/api/userBankCard")
public class UserBankCardController extends UserInfoController {
    @Autowired
    private UserBankCardService userBankCardService;
    /**检查用户是否有添加银行卡**/
    @GetMapping("/checkUserBankCard")
    public ServerResponse checkUserBankCard(HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        return ServerResponse.createBySuccess(userBankCardService.checkUserBankCard(userInfo));
    }

    /**绑定银行卡**/
    @PostMapping
    public ServerResponse addUserBankCard(@RequestBody UserBankCard userBankCard ,HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        userBankCard.setUserInfo(userInfo);
        return userBankCardService.addUserBankCard(userBankCard);
    }


    /**获取已绑定的银行卡号**/
    @GetMapping("/findUserBankCardList")
    public ServerResponse findUserBankCardList(HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        return userBankCardService.findUserBankCardList(userInfo);
    }
}
